<%@ taglib prefix="s" uri="/struts-tags"%>

<script type="text/javascript">	

	var MIN_LEN_PWD = '<s:property value="pwdMinLen" escapeJavaScript="true"/>';
	var MAX_LEN_PWD = '<s:property value="pwdMaxLen" escapeJavaScript="true"/>';
	
	$(document).ready(function() {
		
		<s:if test="%{userInfo != null && userInfo.userId != null}">
			$("#resetUserForm").validate({
		        // validation rules
		        rules: {
		        	'userInfo.userId' : 		{ required : true},
		        	'userInfo.passwordNew' : 	{ minlength: MIN_LEN_PWD, maxlength: MAX_LEN_PWD},
		        	'userInfo.passwordVer' : 	{ minlength: MIN_LEN_PWD, maxlength: MAX_LEN_PWD}
		        },
		        messages: {
		        	
		        	'userInfo.userId': 			{required: "The value is required"},
		        	'userInfo.passwordNew': 	{minlength: "minimun is "+MIN_LEN_PWD+" characters", maxlength: "maximun is "+MAX_LEN_PWD+" characters"},
		        	'userInfo.passwordVer': 	{minlength: "minimun is "+MIN_LEN_PWD+" characters", maxlength: "maximun is "+MAX_LEN_PWD+" characters"}
		        },
		        
		        submitHandler: function(form) {
		            form.submit();
		        }
	    	});
		</s:if>
		<s:else>
		
			$("#resetUserForm").validate({
				
				rules: {
		        	'userInfo.email' : 		{ required : true}
		        },
		        messages: {
		        	'userInfo.email': 			{required: "The value is required"}
		        },
		        submitHandler: function(form) {
		        	form.submit();
		        }
	    	});
		</s:else>
		
		$('#submit_button').click(function(){
			$("#resetUserForm").submit();
		});

	}); 

</script>

<!-- Previously Reset Users -->
<center>
	<h2>Security module - Search/Update Users</h2>
</center>
<br />
<center>
	<s:if test="hasActionMessages()">
		<div style="color: #12c">
			<s:actionmessage escape="false"/>
		</div>     
	</s:if>

		<div style="color: #ff0000">
			<s:actionerror escape="false"/>
		</div>     

	<form name="resetUserForm" id="resetUserForm" action='<s:url action="account/resetUser"/>' method="post">
		<table border="1" cellspacing="1" cellpadding="3" width="70%">
			<s:if test="%{userInfo != null && userInfo.userId != null}">
				<s:hidden name="userInfo.userId"/>
				<s:hidden name="userInfo.email"/>
				<tr border="0">
					<td width="30%" class="center_note">User Login ID: </td>
					<td width="80%" class="center_note"><s:property value="userInfo.email"/></td>
				</tr>
				<tr border="0">
					<td width="30%" class="center_note">User Password: </td>
					<td width="80%" class="center_note"><input type="password" name="userInfo.passwordNew" value="" size=30></td>
				</tr>
				<tr border="0">
					<td width="30%" class="center_note">Confirm User Password: </td>
					<td width="80%" class="center_note"><input type="password" name="userInfo.passwordVer" value="" size=30></td>
				</tr>
				<tr border="0">
					<td width="30%" class="center_note">LOCK: </td>
					
					<td width="80%" class="center_note">
						<s:checkbox name="userInfo.locked" fieldValue="true" value="%{userInfo.locked != null && userInfo.locked.equalsIgnoreCase('Y')}" theme="simple"/></td>
				</tr>
				<tr border="0">
					<td width="30%" class="center_note">ACTIVE: </td>
					<td width="80%" class="center_note">
						<s:checkbox name="userInfo.enabled" fieldValue="true" value="%{userInfo.enabled != null && userInfo.enabled.equalsIgnoreCase('Y')}" theme="simple"/></td>
				</tr>
			</s:if>
			<s:else>
				<tr border="0">
					<td width="30%" class="center_note">User Login ID: </td>
					<td width="80%" class="center_note"><input type="text" name="userInfo.email" value="${userInfo.email}" size=30></td>
				</tr>
			</s:else>

			<tr>
				<td width="30%" class="center_note">&nbsp;</td>
				<td width="80%" class="center_note" align="left">
					<a href="#" class="easyui-linkbutton" id="submit_button">Submit</a>
				</td>
			</tr>
	  	</table>
	</form>
<center>